// map
const map = (array, fn) => {
  let rets = [];
  for (const value of array) {
    rets.push(fn(value));
  }
  return rets;
};

// let arr = [1, 2, 3, 4];
// const ret = map(arr, (v) => v * v);
// console.log(ret);

// every
const every = (array, fn) => {
  let result = true;
  for (const value of array) {
    result = fn(value);
    if (!result) break;
  }
  return result;
};

// let arr = [1, 2, 3];
// const ret = every(arr, (v) => v > 0);
// console.log(ret);

// some
const some = (arr, fn) => {
  let result = false;
  for (const value of arr) {
    result = fn(value);
    if (result) break;
  }
  return result;
};

let arr = [1, 5, 3];
console.log(some(arr, (v) => v % 2 === 0));
